package cn.edu.dz.bank;

public class Client extends Thread{

    // 取款金额
    private int want;

    //共享资源,银行
    private Bank bank;
    //多人进行

    public Client() {
    }

    public Client(String name,int want, Bank bank) {
        super(name);
        this.want = want;
        this.bank = bank;
    }

    @Override
    public void run() {
        int money=0;
        //取款
        money=this.bank.getMoney(want);
        //判断，取款金额大于0时，正常进行取款操作，（若取款失败，则money值为0，取款结束）
        while ((money=this.bank.getMoney(want))>0){
        }
        System.out.println("取款结束");
    }
}
